import React from 'react';
import { View, StyleSheet } from 'react-native';
import DeckList from '../modules/deck/DeckList';
import { useNavigation } from '@react-navigation/native';
import { NativeStackNavigationProp } from '@react-navigation/native-stack';
import { Deck } from '../modules/deck/types';
import SafeAreaView from '../components/SafeAreaView';
import { colors } from '../styles';
type DeckScreenNavigationProp = NativeStackNavigationProp<
  RootStackParamList,
  'Review',
  'DeckDetail'
>;
type RootStackParamList = {
  Review: { deck: Deck }; // 定义Review路由的参数类型
  DeckDetail: { deck: Deck };
};
const DeckScreen: React.FC = () => {
  const navigation = useNavigation<DeckScreenNavigationProp>();

  const handleDeckView = (deck: Deck) => {
    navigation.navigate('Review', { deck });
  };
  const handleDeckManage = (deck: Deck) => {
    navigation.navigate('DeckDetail', { deck });
  };

  return (
    <SafeAreaView style={styles.container}>
      <DeckList onDeckReview={handleDeckView} onDeckManage={handleDeckManage} />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: colors.background,
  },
});

export default DeckScreen;
